package com.eos.business.service;

import java.util.List;
import java.util.Map;

import com.eos.common.tool.DaoAccessObjectPoolContextFactory;
import com.eos.orm.c3p0.dao.AbstractC3p0Dao;
import com.eos.orm.c3p0.dao.impl.ActivtyMappModelDaoImpl;
import com.eos.orm.c3p0.dao.impl.ActivtyMappSalesDaoImpl;
import com.eos.orm.c3p0.dao.impl.SalesModelDaoImpl;
import com.eos.orm.c3p0.dao.impl.SysActivtyDaoImpl;
import com.eos.orm.c3p0.dao.impl.SysActivtySonDaoImpl;
import com.eos.orm.c3p0.dao.impl.SysComboDaoImpl;
import com.eos.orm.mybatis.dao.ActivtyMappModelMapper;
import com.eos.orm.mybatis.dao.ActivtyMappSalesMapper;
import com.eos.orm.mybatis.dao.SalesModelMapper;
import com.eos.orm.mybatis.dao.SysActivtyMapper;
import com.eos.orm.mybatis.dao.SysActivtySonMapper;
import com.eos.orm.mybatis.dao.SysComboMapper;
import com.eos.orm.mybatis.model.ActivtyMappModel;
import com.eos.orm.mybatis.model.ActivtyMappSales;
import com.eos.orm.mybatis.model.SalesModel;
import com.eos.orm.mybatis.model.SalesModelExample;
import com.eos.orm.mybatis.model.SysActivty;
import com.eos.orm.mybatis.model.SysActivtySon;
import com.eos.orm.mybatis.model.SysCombo;
import com.eos.orm.mybatis.model.SysComboExample;
import com.hf.utils.PaginationBean;

public class SysActivityBusinessService  extends AbstractEosService<SysActivty> {
	private SysComboMapper comboMapper = (SysComboMapper) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("SysComboMapper");
	private AbstractC3p0Dao<SysCombo> comboDao = (SysComboDaoImpl) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("SysComboDao");
	
	private SalesModelMapper saleModelMapper = (SalesModelMapper)DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("SalesModelMapper");
	private AbstractC3p0Dao<SalesModel> salesModelDao = (SalesModelDaoImpl)DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("SalesModelDao");
	
	private SysActivtyMapper sysActivityMapper = (SysActivtyMapper) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("SysActivtyMapper");
	private AbstractC3p0Dao<SysActivty> sysActivityDao = (SysActivtyDaoImpl) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("SysActivtyDao");
	
	private SysActivtySonMapper activitySonMapper = (SysActivtySonMapper) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("SysActivtySonMapper");
	
	private AbstractC3p0Dao<SysActivtySon> activitySonDao = (SysActivtySonDaoImpl) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("SysActivtySonDao");
	
	 private ActivtyMappModelMapper activtyModelMapper = (ActivtyMappModelMapper) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("ActivtyMappModelMapper");
	 
	 private AbstractC3p0Dao<ActivtyMappModel> activtyModelDao = (ActivtyMappModelDaoImpl) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("ActivtyMappModelDao");
	 
	 private ActivtyMappSalesMapper activtySalesMapper = (ActivtyMappSalesMapper) DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("ActivtyMappSalesMapper");
	 
	 private AbstractC3p0Dao<ActivtyMappSales> activtySalesDao = (ActivtyMappSalesDaoImpl)DaoAccessObjectPoolContextFactory
		.getInstaAccessObjectPoolContext().instanceDataAccessObject("ActivtyMappSalesDao");
	 
	/**
	 * 保存套餐信息
	 * @param combo
	 * @return
	 */
	public String saveSysCombo(SysCombo combo){
		return comboMapper.insert(combo)==0 ? "SUCCESS" : "FAIL";
	}
	
	/**
	 * 跟据主键修改套餐部分信息
	 * @param combo
	 * @return
	 */
	public String updateSysComboPKSelective(SysCombo combo){
		return comboMapper.updateByPrimaryKeySelective(combo) == 0 ? "SUCCESS" : "FAIL";
	}
	
	/**
	 * 根据主键获取套餐信息
	 * @param comboId
	 * @return
	 */
	public SysCombo getSysComboPrimaryKey(int comboId){
		return comboMapper.selectByPrimaryKey(comboId);
	}
	/**
	 * 分页获取套餐信息
	 * @param map
	 * @return
	 */
	public PaginationBean getSysComboList(Map<String, String> map){
		PaginationBean pageBean = comboDao.findBean(map);
		List<SysCombo> comboList = comboDao.findPage(map);
		pageBean.setResultList(comboList);
		return pageBean;
	}
	
	/**
	 * 获取所有套餐信息
	 * @param combo
	 * @return
	 */
	public List<SysCombo> getAllSysComboExample(SysCombo combo){
		SysComboExample example = new SysComboExample();
		SysComboExample.Criteria cri = example.createCriteria();
		if(combo.getDealFlag() !=null)
			cri.andDealFlagEqualTo(combo.getDealFlag());
		if(combo.getStatus() != null)
			cri.andStatusEqualTo(combo.getStatus());
		return comboMapper.selectByExample(example);
	}
	
	/**
	 * 保存销售方式信息
	 * @param saleModel
	 * @return
	 */
	public String saveSalesModel(SalesModel saleModel){
		return saleModelMapper.insert(saleModel) == 0 ? "SUCCESS" : "FAIL";
	}
	
	/**
	 * 根据主键获取销售方式信息
	 * @param saleModelId
	 * @return
	 */
	public SalesModel getSaleModelPrimaryKey(int saleModelId){
		return saleModelMapper.selectByPrimaryKey(saleModelId);
	}
	
	/**
	 * 根据主键, 修改销售方式部分信息
	 * @param saleModel
	 * @return
	 */
	public String updateSaleModelPKSelective(SalesModel saleModel){
		return saleModelMapper.updateByPrimaryKeySelective(saleModel) == 0 ? "SUCCESS" : "FAIL";
	}
	
	/**
	 * 分页获取销售方式
	 * @param map
	 * @return
	 */
	public PaginationBean getSalesModelList(Map<String, String> map){
		PaginationBean pageBean = salesModelDao.findBean(map);
		List<SalesModel> salesList = salesModelDao.findPage(map);
		pageBean.setResultList(salesList);
		return pageBean;
	}
	
	/**
	 * 获取所有销售方式
	 * @param saleModel
	 * @return
	 */
	public List<SalesModel> getAllSalesModelExample(SalesModel saleModel){
		SalesModelExample example = new SalesModelExample();
		SalesModelExample.Criteria cri = example.createCriteria();
		if(null != saleModel.getStatus())
			cri.andStatusEqualTo(saleModel.getStatus());
		if(null != saleModel.getDealFlag())
			cri.andDealFlagEqualTo(saleModel.getDealFlag());
		return saleModelMapper.selectByExample(example);
	}
	
	/**
	 * 保存活动信息
	 * @param sysActivity
	 * @return
	 */
	public String saveSysActivity(SysActivty sysActivity){
		return sysActivityMapper.insert(sysActivity) ==0?"SUCCESS" : "FAIL";
	}
	
	/**
	 * 根据活动主键, 获取活动信息
	 * @param activityId
	 * @return
	 */
	public SysActivty getSysActivityPrimaryKey(int activityId){
		return sysActivityMapper.selectByPrimaryKey(activityId);
	}
	
	/**
	 * 根据主键,更新活动的部分信息
	 * @param activty
	 * @return
	 */
	public String updateSysActivtyPKSelective(SysActivty activty){
		return sysActivityMapper.updateByPrimaryKeySelective(activty) == 0 ? "SUCCESS" : "FAIL";
	}
	
	/**
	 * 分页获取活动信息
	 * @param map
	 * @return
	 */
	public PaginationBean getSysActivtityList(Map<String, String> map){
		PaginationBean pageBean = sysActivityDao.findBean(map);
		List<SysActivty> activityList = sysActivityDao.findPage(map);
		pageBean.setResultList(activityList);
		return pageBean;
	}
	
	/**
	 * 保存子活动信息
	 * @param sas
	 * @return
	 */
	public String saveSonActivity(SysActivtySon sas){
		return activitySonMapper.insert(sas) == 0 ? "SUCCESS" : "FAIL";
	}
	
	/**
	 * 根据 主键获取子活动信息
	 * @param sonActivityId
	 * @return
	 */
	public SysActivtySon getSonActivityPrimaryKey(int sonActivityId){
		return activitySonMapper.selectByPrimaryKey(sonActivityId);
	}
	
	/**
	 * 根据主键修改子活动部分信息
	 * @param sonActivity
	 * @return
	 */
	public String updateSonActivityPKSelective(SysActivtySon sonActivity){
		return activitySonMapper.updateByPrimaryKeySelective(sonActivity) == 0 ? "SUCCESS" : "FAIL";
	}
	
	/**
	 * 分页获取子活动信息
	 * @param map
	 * @return
	 */
	public PaginationBean getSonActivityList(Map<String, String> map){
		PaginationBean pageBean = activitySonDao.findBean(map);
		List<SysActivtySon> sonList = activitySonDao.findPage(map);
		pageBean.setResultList(sonList);
		return pageBean;
	}
	
	/**
	 *保存活动和型号映射关系
	 */
	public String saveActivityModel(ActivtyMappModel amModel){
		return activtyModelMapper.insert(amModel) == 0 ? "SUCCESS" : "FAIL";
	}
	
	public ActivtyMappModel getActivityModelPrimaryKey(int activityModelId){
		return activtyModelMapper.selectByPrimaryKey(activityModelId);
	}
	
	public PaginationBean getActivityModelList(Map<String, String> map){
		PaginationBean pageBean = activtyModelDao.findBean(map);
		List<ActivtyMappModel> amList = activtyModelDao.findPage(map);
		pageBean.setResultList(amList);
		return pageBean;
	}
	
	/**
	 * 根据主键更新活动型号关系的部分信息
	 * @param amm
	 * @return
	 */
	public String updateActivityModelPKSelective(ActivtyMappModel amm){
		return activtyModelMapper.updateByPrimaryKeySelective(amm) == 0 ? "SUCCESS" : "FAIL";
	}
	
	/**
	 * 保存活动和销售的映射关系
	 * @param activitySales
	 * @return
	 */
	public String saveActivitySales(ActivtyMappSales activitySales){
		return activtySalesMapper.insert(activitySales) == 0 ? "SUCCESS" : "FAIL";
	}
	
	/**
	 * 根据主键ID, 修改活动,销售映射关系的部分信息
	 * @param ams
	 * @return
	 */
	public String udpateActivitySales(ActivtyMappSales ams){
		return activtySalesMapper.updateByPrimaryKeySelective(ams) == 0 ? "SUCCESS" : "FAIL";
	}
	
	/**
	 * 分页查询型号和套餐关系
	 * @param map
	 * @return
	 */
	public PaginationBean getActivitySalesList(Map<String, String> map){
		PaginationBean pageBean = activtySalesDao.findBean(map);
		List<ActivtyMappSales> activitySalesList = activtySalesDao.findPage(map);
		pageBean.setResultList(activitySalesList);
		return pageBean;
	}
	
	/**
	 * 根据主键获取活动和销售方式关系的信息
	 * @param activityMappSalesId
	 * @return
	 */
	public ActivtyMappSales getActivitySalesPrimaryKey(int activityMappSalesId){
		return activtySalesMapper.selectByPrimaryKey(activityMappSalesId);
	}
}
